package com.schoolcloud.common.exception.handle;

import com.schoolcloud.common.exception.UserNotExistException;
import com.schoolcloud.common.exception.LoginUserException;
import com.schoolcloud.common.model.R;
import com.schoolcloud.common.model.REnum;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
public class UserExceptionHandle {
    @ExceptionHandler(value = LoginUserException.class)
    public R<?> LoginUserException(LoginUserException e) {
//        返回登录失效
        return R.err().setMsg(e.getMessage());
    }
    @ExceptionHandler(value = UserNotExistException.class)
    public R<?> UserNotExistException(UserNotExistException e) {
        return R.err(e.getMessage());
    }
}
